package com.gugee.tiktok.common.model.mysql;

import com.gugee.tiktok.common.model.spider.aweme.Text_extra;
import com.xiguaji.boot.data.rdb.aggregate.Aggregate;
import lombok.*;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: luolifeng
 * Date: 2020-10-19 19:44
 */
@Setter
@Getter
//@NoArgsConstructor
//@AllArgsConstructor
@Table("hashtag")
public class Hashtag {

    /**
     * 标签id
     */
    @Column(value="hid")
    private long hid;
    /**
     * 标签名
     */
    @Column(value="hashtag_name")
    private String hashtagName;

    /**
     * 是否商家CollectServiceImpl.java
     */
    @Column(value="is_commerce")
    private boolean commerce;

//    /**
//     * 标签类型
//     */
    @Column(value="type")
    private int type;
//
//    /**
//     * 描述
//     */
//    @Column(value="hashtag_desc")
//    private String hashtagDesc;
//    /**
//     * 观看数
//     */
//    @Column(value="view_count")
//    private long viewCount;
//    /**
//     * 参与人数
//     */
//    @Column(value="user_count")
//    private long userCount;
//    /**
//     * 话题封面图
//     */
//    @Column(value="hashtag_profile")
//    private String hashtagProfile;


    @Mapper(componentModel = "spring")
    public interface HashTagMapper {
        /**
         * Text_extra 转化为 HashTag
         *
         * @param text_extra 采集侧的数据
         * @return
         */
        @Mappings({
                @Mapping(target = "hashtagName", source = "hashtag_name"),
                @Mapping(target = "commerce", expression = "java(changeBoolean(text_extra.isCommerce()))"),
                @Mapping(target = "hid", source = "hashtag_id")
        })
        Hashtag textExtra2HashTag(Text_extra text_extra);



        /**
         * Text_extras 转化为 HashTags
         *
         * @param text_extra 采集侧的数据
         * @return
         */
        List<Hashtag> textExtras2HashTags(List<Text_extra> text_extra);

        default boolean changeBoolean(boolean commerce) {

            return commerce;
        }
    }
}
